package za.um.td.state.client;

import java.util.HashMap;
import java.util.logging.Logger;

import za.um.td.state.client.handler.LevelHandler;

import com.jme.input.InputHandler;
import com.jmex.game.state.BasicGameStateNode;
import com.jmex.game.state.GameState;

public class LevelInputStateNode extends BasicGameStateNode<GameState> {

	// States
	public enum LevelInputState {
		START_PLACING_PLACABLE,
		BUSY_PLACING_PLACABLE,
		STOP_PLACING_PLACABLE
	}
	
	private HashMap<LevelInputState, Boolean> states = new HashMap<LevelInputState, Boolean>();
	
	private static final Logger LOG = Logger
			.getLogger(LevelInputStateNode.class.getName());

	private static final String NAME = "LevelHandlerStateNode";
	private static LevelInputStateNode instance = null;

	private InputHandler input = null;

	private LevelInputStateNode() {
		super(NAME);
	}

	public static LevelInputStateNode createInstance() {
		if (instance == null) {
			instance = new LevelInputStateNode();

			instance.input = new LevelHandler();
		}
		return instance;
	}
	
	public static LevelInputStateNode getInstance() {
		return instance;
	}
	
	public void setStateActive(LevelInputState inputState, boolean active) {
		states.put(inputState, active);
	}
	
	public boolean isStateActive(LevelInputState inputState) {
		Boolean ret = states.get(inputState);
		if (ret == null) return false;
		return ret;
	}

	public void update(float tpf) {
		super.update(tpf);
		input.update(tpf);
	}
}
